package com.springbootbase.springbootproject.controller;

import com.springbootbase.springbootproject.pojo.ListResponse;
import com.springbootbase.springbootproject.pojo.Recommendation;
import com.springbootbase.springbootproject.pojo.Result;
import com.springbootbase.springbootproject.pojo.Student;
import com.springbootbase.springbootproject.service.StudentService;
import com.springbootbase.springbootproject.service.UserService;
import org.mybatis.logging.Logger;
import org.mybatis.logging.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.lang.reflect.Array;
import java.util.ArrayList;

@RestController
@RequestMapping("/student")
public class StudentController {

    @Autowired
    private StudentService studentService;
    @GetMapping("/getStudentInfo")
    public Result<Student> getInfo(Long id) {
        Student student = studentService.findById(id);
        return Result.success(student);
    }

    @PostMapping("/updateStudentInfo")
    public Result updateInfo(@RequestBody @Validated Student student){
        studentService.updateStudent(student);
        return Result.success();
    }


    @GetMapping("/getList")
    public Result getList(Long id,int pageSize,int pageNum){
        ListResponse listResponse = studentService.getList(id,pageSize,pageNum);
        return Result.success(listResponse);
    }

}